class Fibs:
    def __init__(self):
        self.a = 0
        self.b = 1

    def __next__(self):
        self.a, self.b = self.b, self.a + self.b
        return self.a

    def __iter__(self):
        return self


'''从迭代器创建序列'''


class Iterator:
    value = 0

    def __next__(self):
        self.value += 1
        if self.value > 10: raise StopIteration
        return self.value

    def __iter__(self):
        return self


if __name__ == '__main__':
    fibs = Fibs()

    for i in fibs:
        print(r'a:{}, b:{}'.format(fibs.a, fibs.b))
        if i > 100:
            break

    '''
    
     index = 0
     while index < 50:
        print(r'a:{}, b:{}'.format(fibs.a, fibs.b))
        index += 1
        fibs.__next__()
    '''

    next(fibs)
    print(fibs.a)
    next(fibs)
    print(fibs.a)

    print(list(Iterator()))
